package com.mdxx.xczd.ui.activity;

import android.text.TextUtils;
import android.widget.Button;
import com.mdxx.xczd.R;
import com.mdxx.xczd.app.App;
import com.mdxx.xczd.ui.base.BaseActivity;
import com.mdxx.xczd.ui.contract.LoginContract;
import com.mdxx.xczd.ui.model.LoginModel;
import com.mdxx.xczd.ui.presenter.LoginPresenter;
import com.mdxx.xczd.widget.LoginCustomView;
import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by MD-02 on 2017/1/13.
 */

public class LoginActivity extends BaseActivity<LoginPresenter, LoginModel> implements LoginContract.View {

    @BindView(R.id.login_custom1)
    LoginCustomView loginView1;

    @BindView(R.id.login_custom2)
    LoginCustomView loginView2;

    @BindView(R.id.login_custom3)
    LoginCustomView loginView3;

    @BindView(R.id.login_custom4)
    LoginCustomView loginView4;

    @BindView(R.id.btn_login)
    Button mLogin;

    private String password;

    @Override
    protected int getLayout() {
        return R.layout.activity_login;
    }

    @Override
    protected void init() {}

    @Override
    public void initPresenter() {
        mPresenter.setVM(this, mModel);
    }

    @Override
    public void returnLoginData() {
        startActivity(TaskActivity.class);
        finish();
    }

    @Override
    public void showLoading(String title) {}

    @Override
    public void stopLoading() {}

    @Override
    public void showErrorTip(String msg) {}

    @OnClick(R.id.btn_login)
    void onClick() {
        submit();
    }

    public void submit() {
        password = loginView1.getNum()+ loginView2.getNum()
                + loginView3.getNum() + loginView4.getNum();
        if (!TextUtils.isEmpty(password)) {
            mPresenter.getLoginRequest(App.USERID, password);
        }
    }

}
